<include file="public:header"/>
<div class="toptip">
    <div class="toptit">提示：</div>
    <p>服务套餐模式是指会员可以购买不同等级服务，如普通会员，VIP会员等，每个等级都有不同的使用权限</p>
</div>
<div class="toptit">修改服务套餐</div>
<!--<form id="form1" action="{:U('edit')}" method="post" enctype="multipart/form-data">-->
<!--    <div class="form_main width200">-->
<!--        <div class="fl">套餐名称:</div>-->
<!--        <div class="fr">-->
<!--            <input name="setmeal_name" type="text" class="input_text_default middle" maxlength="15" value="{$info['setmeal_name']}"/>-->
<!--        </div>-->
<!--        <div class="form_main width200">-->
<!--            <div class="fl">套餐权益:</div>-->
<!--            <div class="fr">-->

<!--                <table>-->
<!--                    <th>-->
<!--                        <input type="text" value="{$info['name']}" name="name"/>-->
<!--                    </th>-->
<!--                    <th>-->
<!--                        <input type="text" value="{$info['pt_name']}" name="pt_name"/>-->
<!--                    </th>-->
<!--                    <th>-->
<!--                        <input type="text" value="{$info['vip_name']}" name="vip_name"/>-->
<!--                    </th>-->
<!--                    <tbody id="add">-->

<!--                    <volist name="info.name_val"   id="row" key="k">-->
<!--                    <tr>-->
<!--                        <td><input name="name_val[]" value="{$row}" type="text" /></td>-->
<!--                        <td><input type="text" value="{$info['pt_val'][$k]}" name="pt_val[]" /></td>-->
<!--                        <td><input type="text" value="{$info['vip_val'][$k]}" name="vip_val[]" /></td>-->
<!--                        <td><button onclick="add_tr(this)" type="button">+</button></td>-->
<!--                    </tr>-->
<!--                    </volist>-->
<!--                    </tbody>-->

<!--                </table>-->
<!--            </div>-->
<!--        </div>-->


<!--            <div class="fl">显示状态:</div>-->
<!--            <div class="fr">-->
<!--                <div class="imgradio">-->
<!--                    <input name="display" type="hidden" value="{$info['display']}">-->
<!--                    <div class="radio <eq name='info.display' value='1'>select</eq>" data="1" title="正常">正常</div>-->
<!--                    <div class="radio <eq name='info.display' value='0'>select</eq>" data="0" title="屏蔽">屏蔽</div>-->
<!--                    <div class="clear"></div>-->
<!--                </div>-->
<!--            </div>-->


<!--        <div class="fl"></div>-->
<!--        <div class="fr">-->

<!--            <input type="hidden" name="id" value="{$info['id']}">-->
<!--            <input type="button" class="admin_submit" value="提交" id="J_submit"/>-->
<!--            <input type="button" class="admin_submit" value="返回" onClick="history.go(-1)"/>-->
<!--        </div>-->
<!--        <div class="clear"></div>-->
<!--    </div>-->
<!--</form>-->
<form id="form1" action="{:U('edit')}" method="post" enctype="multipart/form-data">
    <div class="form_main width200">
        <div class="fl">套餐名称:</div>
        <div class="fr">
            <input name="name" type="text" class="input_text_default middle" maxlength="15" value="{$info['name']}"/>
        </div>

        <div class="fl">价格:</div>
        <div class="fr">
            <input name="price" type="text" class="input_text_default middle" maxlength="10" value="{$info['price']}"/> 元
            <label class="no-fl-note">(0表示免费)</label>
        </div>
        <div class="fl">折扣:</div>
        <div class="fr">
            <input name="price_rate" type="text" onkeyup="if(event.keyCode !=37 && event.keyCode != 39) value=value.replace(/\D/g,'');" class="input_text_default middle" maxlength="10" value="{$info['price_rate']}"/> %
            <label class="no-fl-note">(0表示不打折)</label>
        </div>

        <div class="fl">数量:</div>
        <div class="fr">
            <input name="num" type="text" class="input_text_default middle" maxlength="10" value="{$info['num']}"/> 元
            <label class="no-fl-note"></label>
        </div>

        <div class="fl">赠送数量:</div>
        <div class="fr">
            <input name="send_num" type="text" class="input_text_default middle" maxlength="10" value="{$info['send_num']}"/> 元
            <label class="no-fl-note"></label>
        </div>

        <if condition="$info['id'] neq 1">
            <div class="fl">显示状态:</div>
            <div class="fr">
                <div class="imgradio">
                    <input name="display" type="hidden" value="{$info['display']}">
                    <div class="radio <eq name='info.display' value='1'>select</eq>" data="1" title="正常">正常</div>
                    <div class="radio <eq name='info.display' value='0'>select</eq>" data="0" title="屏蔽">屏蔽</div>
                    <div class="clear"></div>
                </div>
            </div>
        </if>

        <div class="fl"></div>
        <div class="fr">
            <if condition="$info['id'] eq 1">
                <input type="hidden" name="display" value="1">
            </if>
            <input type="hidden" name="id" value="{$info['id']}">
            <input type="button" class="admin_submit" value="提交" id="J_submit"/>
            <input type="button" class="admin_submit" value="返回" onClick="history.go(-1)"/>
        </div>
        <div class="clear"></div>
    </div>
</form>
</div>
<include file="public:footer"/>
</body>
<script type="text/javascript">
  var uploadUrl = "{:U('Upload/form_upload')}";
</script>
<script src="__ADMINPUBLIC__/js/ajaxfileupload.js"></script>
<script src="__ADMINPUBLIC__/js/fileupload.js"></script>
<script type="text/javascript">

    function add_tr(obj)
    {
        console.log($(obj).parent().parent().children('td').first().find('input').val() );
        var html='';
        html+=" <tr>\n" +
            "            <td><input name='name_val[]' value='11' type=\"text\" /></td>\n" +
            "            <td><input name='pu_bal[]' type=\"text\" /></td>\n" +
            "            <td><input name='vip_val[]' type=\"text\" /></td>\n" +
            "            <td><button onclick=\"add_tr(this)\" type=\"button\">+</button></td>\n" +
            "            <td><button onclick=\"jian_tr(this)\" type=\"button\">-</button></td>\n" +
            "        </tr>";
        $('#add').append(html)
        //  $(obj).parent().
    }
    function jian_tr(obj)
    {
        $(obj).parent().parent().remove();
    }
  $(document).ready(function () {
    $('#J_submit').click(function(){
            var that = $(this);
            if(that.hasClass('disabled')){
                return false;
            }
            that.val('正在保存...').addClass('disabled');
            $.post("{:U('edit')}",$('#form1').serialize(),function(result){
                if(result.status==1){
                    disapperTooltip("success", result.msg,function(){
                        location.href='{:U("SetCom/set_gcb")}';
                    });
                }else{
                    disapperTooltip("remind", result.msg,function(){
                        that.val('保存').removeClass('disabled');
                    });
                    return false;
                }
            },'json');
        });
    // 上传网站首页Logo
    $.upload('#J_upload_meal_img',{name:'setmeal_img',dir:'setmeal_img',id:eval("{$info['id']}")},function(result){
      if(result.error == 1){
        var htmlResult = '<img src="'+ result.url.src +'" align=absmiddle>';
        $('#J_upload_meal_img').closest('.J-file-input-box').find('.file-input-src .img').html(htmlResult);
        $('#J_upload_meal_img').closest('.J-file-input-box').find('.file-input-save-name').val(result.url.savename);
        if ($('#J_upload_meal_img').hasClass('file-input-block')) {
          $('#J_upload_meal_img').closest('.J-file-input-box').find('.file-input-src').removeClass('hid');
          var $delObj = $('#J_upload_meal_img').closest('.J-file-input-box').find('.file-input-del');
          $('#J_upload_meal_img').remove();
          $delObj.attr('id', "J_upload_meal_img_change_btn");
          $.upload('#J_upload_meal_img_change_btn',{name:'setmeal_img',dir:'setmeal_img'},function(result){
            if(result.error == 1){
              var htmlResult = '<img src="'+ result.url.src +'" align=absmiddle>';
              $('#J_upload_meal_img_change_btn').closest('.J-file-input-box').find('.file-input-src .img').html(htmlResult);
              $('#J_upload_meal_img_change_btn').closest('.J-file-input-box').find('.file-input-save-name').val(result.url.savename);
            } else {
              disapperTooltip("remind", "上传失败："+result.message);
            }
          })
        }
      } else {
        disapperTooltip("remind", "上传失败："+result.message);
      }
    });
  });
</script>
</html>